import static org.junit.Assert.*;

import java.util.Vector;

import org.junit.Test;


public class StorageTest {

	@Test
	public void testRetrieveData() {
		Storage test = new Storage("test.txt");
		test.add(new Task("kill bill",null,null,"100"), 0);
		test.add(new Task("kill john",null,null,"101"), 1);
		test.add(new Task("save me",null,null,"102"), 2);
		Vector<Task> datasb4Del = test.retrieveData();
		int b4Del = datasb4Del.size();
		test.deleteTask("101");
		Vector<Task> datasAfterDel = test.retrieveData();
		int afterDel = datasAfterDel.size();
		assertTrue((b4Del == 3) && (afterDel == 2));
	}
	
	@Test
	public void testRetrieveTask() {
		Storage test = new Storage("test.txt");
		test.add(new Task("kill bill",null,null,"100"), 0);
		test.add(new Task("kill john",null,null,"101"), 1);
		test.add(new Task("save me",null,null,"102"), 2);
		Task a = test.retrieveTask("102");
		assertTrue(a.getDescription().equals("save me"));
	}
	
	@Test
	public void testSearch() {
		Storage test = new Storage("test.txt");
		test.add(new Task("kill bill",null,null,"100"), 0);
		test.add(new Task("kill john",null,null,"101"), 1);
		test.add(new Task("save me",null,null,"102"), 2);
		Vector<Task> b = test.search("kill");
		assertTrue(b.size() == 2);
	}

}
